export default {
    namespaced: true,
    state: {
        //imageMap: [],
        dateList: [],
        checkedImgsArr: [], //已被选择的id的多维数组
        checkedImgs: [],//已被选择的id的一维数组
    },
    getters: {
        selectedCount: state => {
            return state.checkedImgs.length
        }
    },
    mutations: {
        clearChecked(state) {
            state.checkedImgs = []
            for (var i = 0; i < state.dateList.length; i++) {
                state.checkedImgsArr[i] = []
            }
        },
        storeImageInfo(state, value) {
            state.dateList = value["dateList"]
        },
        storeCheckedImgs(state, payload) {
            let orderIndex = payload.orderIndex
            let checkedImgs = payload.checkedImgs
            state.checkedImgsArr[orderIndex] = checkedImgs.slice(0)
            state.checkedImgs = []
            for (var i = 0; i < state.dateList.length; i++) {
                state.checkedImgs = state.checkedImgs.concat(state.checkedImgsArr[i])
            }
        },
        storeCheckedImgsInAlbum(state, payload) {
            state.checkedImgs = payload
        }
    },
    actions: {
        storeImageInfo(store, value) {
            store.commit('storeImageInfo', value)
        }
    }
}